﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;

namespace Tilver.Coder.Win.Controls
{
    public partial class TextEditor : TextEditorControl
    {
        private IHighlightingStrategy _csHighlightng = HighlightingStrategyFactory.CreateHighlightingStrategy("C#");
        private IHighlightingStrategy _sqlHighlightng = HighlightingStrategyFactory.CreateHighlightingStrategy("TSQL");

        private CodeTypeEnum _codeType;
        [EditorBrowsable]
        [Description("代码类型")]
        [Category("Extends")]
        public CodeTypeEnum CodeType
        {
            get { return _codeType; }
            set
            {
                _codeType = value;
                switch (value)
                {
                    case CodeTypeEnum.CS:
                        Document.HighlightingStrategy = _csHighlightng;
                        break;
                    case CodeTypeEnum.SQL:
                        Document.HighlightingStrategy = _sqlHighlightng;
                        break;
                }
            }
        }

        public TextEditor()
        {
            IsIconBarVisible = false;
            ShowEOLMarkers = false;
            ShowSpaces = false;
            Document.HighlightingStrategy = _csHighlightng;
            Encoding = Encoding.UTF8;

            InitializeComponent();
        }
    }


    public enum CodeTypeEnum
    {
        CS,
        SQL
    }
}
